package com.ymatou.iapi.livebuyer.testcase;

import java.math.BigDecimal;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livebuyer.parameter.SyncLiveHeatBean;
import com.ymatou.iapi.livebuyer.service.SyncLiveHeatCall;
import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
/**
*同步直播间热度
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SyncLiveHeat{
	private static SyncLiveHeatBean syncliveheatBean;
	private static SyncLiveHeatCall syncliveheatCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("同步直播间热度");
	}

	@Before
	public void caseUp() {
		syncliveheatBean=new SyncLiveHeatBean();
		syncliveheatCall=new SyncLiveHeatCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(syncliveheatCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SyncLiveHeat_001() {
		Logger.start(true,"同步直播间热度查询成功");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			Integer liveId = livedto.getId();
			syncliveheatBean.setHeat(1.2);
			syncliveheatBean.setLiveId(liveId);
			syncliveheatCall.setData(syncliveheatBean);
			syncliveheatCall.callService();			
			Logger.verifyEquals("ok", syncliveheatCall.getReturnData(), "验证返回");
			Thread.sleep(10000);
			Map liveroom =new LiveRoomWapper().selectLiveRoomStatById(liveId);
			Logger.debug(liveroom);
			Logger.verifyEquals(BigDecimal.valueOf(syncliveheatBean.getHeat()).setScale(2),((BigDecimal)liveroom.get("Heat")).setScale(2), "验证Heat");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}